import java.util.Arrays;

public class Solution205 {
    public boolean isIsomorphic(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        int[] mapS = new int[128];
        int[] mapT = new int[128];
        Arrays.fill(mapS, -1);
        Arrays.fill(mapT, -1);
        for (int i = 0; i < s.length(); i++) {
            char si = s.charAt(i), ti = t.charAt(i);
            if (mapS[si] == -1 && mapT[ti] == -1) {
                mapS[si] = ti;
                mapT[ti] = si;
            } else if (mapS[si] == -1 || mapT[ti] == -1) {
                return false;
            } else if (mapS[si] != ti || mapT[ti] != si) {
                return false;
            }
        }
        return true;
    }
}
